<%@page import="com.baoyanghui.model.Request"%>
<%@page import="com.baoyanghui.common.Constants"%>
<%@page import="com.baoyanghui.model.CarInfo"%>
<%@page import="com.baoyanghui.model.MerchantType"%>
<%@page import="java.lang.reflect.Field"%>
<%@page import="net.sf.json.JSONArray"%>
<%@page import="com.baoyanghui.model.ResultObject"%>
<%@page import="com.baoyanghui.common.DataChanger"%>
<%@page import="com.baoyanghui.common.InterfaceAccess"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.List"%>
<%@page import="com.baoyanghui.model.MerchantPlace"%>
<%@page import="com.baoyanghui.model.Merchant"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="com.baoyanghui.config.Configs"%>
<%@page import="com.baoyanghui.common.Utils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<script type="text/javascript" src="<%= request.getContextPath() %>/js/my_request.js"></script>
<% 
	if (Utils.empty((String)request.getSession().getAttribute(Configs.SESSION_USER_ID))
			|| (Constants.USER_TYPE_MERCHANT == (Integer)request.getSession().getAttribute(Configs.SESSION_USER_TYPE))) {
		response.getWriter().print("<script type='text/javascript'>\n");
		response.getWriter().print("window.location.href='" + request.getContextPath() + "/index.jsp';\n");
		response.getWriter().print("</script>\n");
		response.getWriter().flush();
		return;
	}

	String errorMessage = (String)session.getAttribute("error_message"); 
	session.removeAttribute("error_message");

	JSONObject myRequests = null;
	Request myRequest = null;
	List<Request> requestList = null;
	Map<String, String> params = new HashMap<String, String>();
	
	try {
		request.setCharacterEncoding("UTF-8");
		
		params.put("customer_id", (String)session.getAttribute(Configs.SESSION_USER_ID));
		params.put("usercode", (String)session.getAttribute(Configs.SESSION_USERCODE));
		
		myRequests = InterfaceAccess.callInterface("/customer/get_my_requests", params);
		requestList = (List<Request>)JSONArray.toList(myRequests.getJSONObject("resultData").getJSONArray("items"), Request.class);
	} catch (Exception e) {
	}
%>
       		<div style="width: 350px; height:850px; float: left; position: relative; top: -5px; background: url('../image/line_vertical_gradient.png') right repeat-y;">
<%
	for (int i = 0; requestList != null && i < requestList.size(); i++) {
		myRequest = requestList.get(i);
		String type = ((Constants.REQUEST_TYPE_HELP + "").equals(myRequest.getType())) ? "<求帮助>" : "<求养护>";
%>
				<div style="height: 75px; margin-left: 10px; border-bottom: 1px solid #e1e1e1; cursor: pointer;"
					onclick="showRequestDetail('<%= myRequest.getId() %>');">
					<div>
						<h3 style="padding: 8px 0px;"><%= type + myRequest.getContent().substring(0, 15) %></h3>
					</div>
					<div>
						<span style="width: 160px; display: inline-block;">发布日期：<%= myRequest.getDate() %></span>
<%
	if ((Constants.REQUEST_TYPE_HELP + "").equals(myRequest.getType())) {
%>
						<span style="width: 160px; display: inline-block;">剩余时间：<%= Utils.getStrTime2(Long.parseLong(myRequest.getRemainTime())) %></span>
<%
	}
%>
						<br/>
					</div>
				</div>
<%
	}
%>
			</div>
			<div id="div_maintain_request_detail" style="width: 400px; height:850px; float: left; position: relative; top: -5px; padding-left: 10px;
				background: url('../image/line_vertical_gradient.png') right repeat-y; display: none;">
			</div>
			<div style="clear: both;"></div>